(function (win, $) {
    var LXT = {};
    LXT.Cmd = function (url) {
        this.url = url;
        this.async = false;
        this.param = {};
    };

    LXT.Cmd.prototype = {
        setUrl: function (url) {
            this.url = url;
        },
        setParameter: function (key, value) {
            this.param[key] = value;
        },
        setAsync: function (async) {
            this.async = async;
        },
        getData: function () {
            return this.data;
        },
        execute: function (callback) {
            var that = this;
            if (that.async == null) {
                that.async = false;
            }
            var config = {
                url: that.url,
                data: that.param,
                dataType: 'json',
                async: that.async,
                type: 'POST',
                success: function (result, status, xhr) {
                    that.data = result;
                    if (callback) {
                        callback(result, status, xhr);
                    }
                }
            };
            $.ajax(config);
        }
    };
    LXT.Util = {
        startWith: function (str, substr) { // str是否以substr开头
            var reg = new RegExp("^" + substr);
            return reg.test(str);
        },
        endWith: function (str, substr) { // str是否以substr结尾
            var reg = new RegExp(substr + "$");
            return reg.test(str);
        }
    };
    win.LXT = LXT;
})(window, jQuery);